<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html>
<html>
    <head>
    	<title>一笑网-资料修改</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="../../static/layui/css/layui.css" />
        <link rel="stylesheet" href="../../static/css/yx.css" />
        <script src="../../static/js/jquery-2.1.4.min.js" ></script>
        <script type="text/javascript" src="../../static/layui/layui.all.js" ></script>
        <script src="../../static/js/yx.js" >/*公共js*/</script>
        <style type="text/css">
        	.cc{margin: 1em auto;background-color: #FFF;}
        	.c0{min-height: 20rem;}
        	.c1{width: 20rem;float: left;border-right: 1px #CCC solid;}
        	.c2{width: calc(100% - 21rem);float: right;min-height: 40rem;}
        	
        	.user_tx_fox{width: 20rem;float: left;}
        	.user_img{width: 70%;margin: 15%;}
        	.c0{line-height: 1.2em;}
        	
        	/* 功能按钮 */
			
			/* 右边盒子 */
			.c2{padding: 0.8em 0em;}
			
			
			.yu-head{margin-top: -1em; margin-bottom: 0.5em; text-indent: 1em;}
			.fx7{padding: 2em;}
			.fx7 input{height: 2em;max-width: 20rem;margin: 5px 0px;}
			
        	
        	
        </style>
        <script>
        	$(function(){
        		layui.form.render();	//渲染一下下拉列表框
        		
        		
        		//保存
		  		$(".up_ok").click(function(){
		  			
		  			$.post2("doUpUseeInfo.ajax",$(".up_from").serialize(),function(data){
		  				if(data.res==-9){
		  					return layer.msg('未登录');
		  				}
		  				if(data.res==-1){
		  					return layer.msg(data.msg);
		  				}
		  				if(data.res==1){
		  					location.href="rus.html?uid=${login_usee.uid}";
		  				}else{
		  					layer.alert("失败");
		  				}
		  				
		  			},function(e,ee,eee){
		  				layer.alert(eee);
		  			})
		  			
		  		})
		  		
		  		////修改密码
        		$(".update_pwd").click(function(){
        			//捕获页
					layer.open({
						type: 1,
						shade: false,
						title: false, //不显示标题
						maxWidth:500,
						content: $('.uppwdfox'), 
						cancel: function(){
							layer.msg('你取消了', {time: 5000, icon:6});
					 	}
					});
        			return false;
        		})
        		
        		//点击修改密码
        		$(".gouppwd").click(function(){
        			
        			var pwd=$("[name=pwd]").val();
        			var pwd2=$("[name=pwd2]").val();
        			var newpwd=$("[name=newpwd]").val();
        			var newpwd2=$("[name=newpwd2]").val();
        			if(pwd!=pwd2||newpwd!=newpwd2){
        				return layer.msg("请保持输入密码与确认密码的一致");
        			}
        			if(pwd.length<6||newpwd.length<6){
        				return layer.msg("为了账号安全，请不要让密码长度太短");
        			}
        			
        			$.post2("do_update_pwd.ajax",{pwd:pwd,newpwd:newpwd},function(data){
        				if(data.res==-1){return layer.msg(data.msg);}
        				if(data.res==0){return layer.msg("修改失败，原因未知");}
        				if(data.res==1){
        					layer.closeAll();
        					layer.msg("修改成功");
        					location.href="rus.html?uid=${login_usee.uid}";
        				}
        			},function(e,ee,eee){
        				layer.alert('异常：'+eee)
        			})
        		})
        		
        		
        		var upload = layui.upload;
        		upload.render({
					elem: '.up_tou' 				//绑定元素
					,url: 'uptouimg.ajax' 	//上传接口
					,done: function(data){
						if(data.res=="-1"){return layer.msg(data.msg);}
					  	//上传完毕回调
					  	if(data.res==1){
					  		layer.alert('头像已经修改成功，温馨提示：部分浏览器在更换头像后需要 强制刷新[Ctrl+F5] 或清除缓存[Ctrl+Shift+R]，请参考你所使用的浏览器',function(){
					  			location.href="rus.html?uid=${login_usee.uid}";
					  		})
					  	}else{
					  		layer.msg("上传失败");
					  	}
					}
					,error: function(e,ee){
						layer.alert("上传失败，异常："+e);
				    }
				});
        		
        		
        		
        		
        		
        		
        	})
        </script>
    </head>
    <body class="rus-html">
    	<div class="aa"> 
    		<%@include file="../in/in_head.jsp"%> <!-- 头部导入 -->
    	</div>
    	
    	<!-- 身体部分 -->
    	<div class="cc yx-max-width">
    		
    		<!-- 头部，基本资料部分 -->
    		<div class="c0">
    			<div class="user_tx_fox">
    				<img class="user_img" src="../../static/tu/${login_usee.uid}/tou.png" onload="this.style.height=this.offsetWidth+'px'" />
    			</div>
    			
    			<br /><br />
    			<span>ID：${login_usee.uid}</span><br /><br />
    			<span class="yx-color-one"><big>${login_usee.uname}</big></span><br /><br />
    			<span style="padding-left: 1em;">${login_usee.uxy}</span>
    			
    		</div>
    		
    		<div class="c1 yx-phone-max">
    			<br />
    		</div>
    		
    		<div class="c2 yx-phone-max">
    			<h3 class="yu-head yx-color-one">资料修改</h3>
    			<div class="fx7">
					<form class="up_from layui-form" action="#" method="post">
			    		<input type="radio" name="sex" value="男" title="男" ${login_usee.sex=='男'?'checked':''}>
			    		<input type="radio" name="sex" value="女" title="女" ${login_usee.sex=='女'?'checked':''}>
			    		<input type="radio" name="sex" value="略" title="略" ${login_usee.sex=='略'?'checked':''}>
						<input name="uname" class="layui-input" placeholder="昵称" value="${login_usee.uname}"/>
			    		<input name="uxy" class="layui-input" placeholder="个人介绍" value="${login_usee.uxy}"/>
			    		<button class="up_ok layui-btn layui-btn-sm layui-btn-danger" type="button">确认</button>
			    		<button class="up_tou layui-btn layui-btn-sm layui-btn-danger" type="button">上传头像</button>
			    		<button class="update_pwd layui-btn layui-btn-sm layui-btn-danger" type="button">密码修改</button>
					</form>
    			</div>
    		</div>
    		
    		
    		<div style="clear: both;"></div>
    		
    	</div>
    	
    	<!-- 修改密码盒子，以便layer的捕捉 -->
    	<div style="width: 0px;height: 0px;overflow: hidden;">
    		<div class="uppwdfox" style="padding:20px 50px;width: 300px;">
    			<br />
	    		<input type="password" name="pwd" class="layui-input" placeholder="旧密码"/><br />
	    		<input type="password" name="pwd2" class="layui-input" placeholder="再次输入旧密码"/><br />
	    		<input type="password" name="newpwd" class="layui-input" placeholder="新的密码" /><br />
	    		<input type="password" name="newpwd2" class="layui-input" placeholder="再次确认新的密码" /><br />
	    		<button class="gouppwd layui-btn layui-btn-sm">确认</button>
	    	</div>
    	</div>
    	
    	
    	<!-- 页面底部 版权部分 -->
    	<div class="ff">
    		<%@include file="../in/in_bottom.jsp"%> <!-- 底部导入 -->
    	</div>
    	
    	
 	</body>
</html>